<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); ?>

<?php 
	$ci = & get_instance();
	$tid = intval($_GET['tid']);
	$mid = intval($_GET['mid']);
	$TOURNAMENT = $ci->tournament_entity->init("id", $tid);
	$match_array = $ci->match_entity->getMatchOfTournamentByStatus($tid, 'upcoming');
?>

<div class="block">
	<div class="title"><span class="betticker" rel="div_upcoming_matches">&nbsp;</span><h3 class="bold">UpComing Matches</h3></div>
	<div class="clrboth"></div>
	<div class="content" id="div_upcoming_matches">
	<?php foreach($match_array as $item): ?>
	<?php if($mid != $item->id):?>
		<?php 
			$MATCH = $ci->match_entity->init('id', $item->id);
			$TEAM_HOME = clone_($ci->team_entity->init('id', $MATCH->getHome()));
			$TEAM_AWAY = clone_($ci->team_entity->init('id', $MATCH->getAway()));
		?>
		<div class="rowitem2">
			<div class="grid1">&nbsp;</div>
			<div class="grid6" style="text-align:center;"><h4><?php echo $MATCH->getTitle();?></h4></div>
			<div class="clrboth"></div>
			
			<div class="grid3">
				<div class="team">
					<?php echo thumb($TEAM_HOME->getMyFlagTeam(),IMG_TEAMPIC_W,IMG_TEAMPIC_H);?>
					<div class="clrboth"></div>
					<span class="bold"><?php echo $MATCH->displayMatchInfo('home');?></span>
					<div class="clrboth"></div>
				</div>
			</div>
			
			<div class="grid1" style="text-align:center;width:80px;"><?php echo vs_image(); ?></div>
			
			<div class="grid3">
				<div class="team">
					<?php echo thumb($TEAM_AWAY->getMyFlagTeam(),IMG_TEAMPIC_W,IMG_TEAMPIC_H);?>
					<div class="clrboth"></div>
					<span class="bold"><?php echo $MATCH->displayMatchInfo('away');?></span>
					<div class="clrboth"></div>
				</div>
			</div>
		<!--	<div class="grid1">&nbsp;</div>	-->
			<div class="grid4" style="position:relative;">
				<span class="predict" onclick="go_predict_upcoming(<?php echo $TOURNAMENT->getId();?>,<?php echo $MATCH->getId();?>,'<?php echo mCrypt($TOURNAMENT->getId().$MATCH->getId());?>');"></span>
				<div class="clrboth"></div>
				<div class="clock-wrap">
					<div class="wrap">
						<div class="title-clock">STARTS IN: </div>
						<div class="clrboth"></div>
						<span class="yellow countdown upper" id="match_mid_<?php echo $MATCH->getId();?>" rel="<?php echo ($MATCH->getStartTime() - time() );?>"></span> 
					</div>
				</div>
			</div>
			 
			<div class="clrboth"></div>
			<div class="grid7">
				<div class="result-text" style="text-align:center;"><?php echo $MATCH->displayMatchInfo('closed');?></div>
			</div>
			<div class="clrboth"></div>
		</div>
		<div class="clrboth"></div>
	<?php endif;?>
	<?php endforeach;?>	
		
	</div>
</div>		